package rsj.service.report;

import com.alibaba.fastjson.JSON;
import com.rlyy.aibase.utils.base.TableNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import rsj.api.report.entity.ExportLogParam;
import rsj.api.report.entity.ReportExportLog;
import rsj.sql.exportlog.ExportLogDao;

import java.util.List;

/**
 * 我的导出列表
 *
 * @author yuanqinglong
 * @since 2021/7/28 16:53
 */
@Service
public class MyExportServiceImpl implements IMyExportService {


    @Autowired
    private ExportLogDao exportLogDao;


    /**
     * 我的导出列表
     *
     * @param exportLogParam 导出日志参数
     * @return {@link List<ReportExportLog>}
     */
    @Override
    public List<ReportExportLog> myExportList(ExportLogParam exportLogParam) {
        TableNode exportList = exportLogDao.myExportList(exportLogParam.getUserId(), exportLogParam.getPageInfo().getPageSize(), exportLogParam.getPageInfo().getPageOffSet());
        return JSON.parseArray(exportList.toJson(), ReportExportLog.class);
    }

    /**
     * 我的导出数
     *
     * @param exportLogParam 导出日志参数
     * @return int
     */
    @Override
    public int myExportCount(ExportLogParam exportLogParam) {
        return exportLogDao.myExportCount(exportLogParam.getUserId()).valueInt();
    }

}
